import request from "@/utils/request.ts";
import { AxiosProgressEvent } from 'axios'
import {ICommonResponse, ISqlUpdate} from "@/global.ts";

export const uploadProfile = (data: FormData): Promise<ICommonResponse<{ path: string }>> => {
    return request({
        url: '/upload/profile',
        method: 'POST',
        data
    })
}

export const uploadFile = (data: FormData, onUploadProgress: (progressEvent: AxiosProgressEvent) => void): Promise<ICommonResponse<{ msg: string }>> => {
    return request({
        url: '/upload/file',
        method: 'POST',
        data,
        onUploadProgress
    })
}

export const flowAdd = (data: FormData): Promise<ICommonResponse<ISqlUpdate>> => {
    return request({
        url: '/upload/flow',
        method: 'POST',
        data
    })
}

export const fileBlob = (fileName: string): Promise<Blob> => {
    return request({
        url: '/static/file/' + fileName,
        method: "GET",
        responseType: 'blob'
    })
}